Surface meshes
SurfaceMesh
Bases: Mesh
A data structure for representing polygonal surfaces.
Attributes:
Name | Type | Description |
---|---|---|
vertices |
DataContainer
|
the container for all vertices |
edges |
DataContainer
|
the container for all edges |
faces |
DataContainer
|
the container for all faces |
face_corners |
DataContainer
|
the container for all corner of faces |
boundary_edges |
list
|
list of all edge indices on the boundary |
interior_edges |
list
|
list of all interior edge indices (all edges \ boundary_edges) |
boundary_vertices |
list
|
list of all vertex indices on the boundary |
interior_vertices |
list
|
list of all interior verticex indices (all vertices \ boundary_vertices) |
connectivity |
_SurfaceConnectivity
|
the connectivity utility class |
id_corners
property
Shortcut for range(len(self.face_corners))
id_edges
property
Shortcut for range(len(self.edges))
id_faces
property
Shortcut for range(len(self.faces))
id_vertices
property
Shortcut for range(len(self.vertices))
clear_boundary_data()
Clear all boundary data. Next call to a boundary/interior container or method will recompute everything
is_edge_on_border(u, v)
whether edge (u,v) is a boundary edge or not
Parameters:
Name | Type | Description | Default |
---|---|---|---|
u |
int
|
vertex id |
required |
v |
int
|
vertex id |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
whether edge (u,v) is a boundary edge or not. Returns False if (u,v) is not a valid edge. |
is_quad()
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if the mesh is quadrangular (all faces are quad) |
is_triangular()
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if the mesh is triangular (all faces are triangles) |
is_vertex_on_border(u)
whether vertex u
is a boundary vertex or not.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
u |
int
|
vertex id |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
whether vertex |
ith_vertex_of_face(fid, i)
helper function to get the i-th vertex of a face, i.e. self.faces[fid][i]
Parameters:
Name | Type | Description | Default |
---|---|---|---|
fid |
int
|
face id |
required |
i |
int
|
vertex id in face. Should be 0 <= vid < len(face) |
required |
Returns:
Name | Type | Description |
---|---|---|
int |
int
|
the id of the i-th vertex in face |
pt_of_face(fid)
point coordinates of vertices of face fid
Parameters:
Name | Type | Description | Default |
---|---|---|---|
fid |
int
|
face id |
required |
Returns:
Name | Type | Description |
---|---|---|
Iterable |
iterator of Vec objects representing point coordinates of vertices |
Surface Connectivity
Bases: _Connectivity
Connectivity for surface meshes. Is accessed via the .connectivity
attribute of the SurfaceMesh
class.
Warning
If your mesh is not manifold, there is no guarantee that the connectivity arrays will be correct.
clear()
Resets connectivity. The next query in the code will regenerate internal arrays.
common_edge(iF1, iF2)
Returns the two vertices (u,v) of the edge that separates faces iF1 and iF2 if it exists, and (None,None) otherwise.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
iF1 |
int
|
first face index |
required |
iF2 |
int
|
second face index |
required |
Returns:
Type | Description |
---|---|
(int, int)
|
(u,v) pair of vertex indices, or (None,None) |
corner_to_face(C)
The face inside which corner C
belongs.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
C |
int
|
corner id |
required |
Returns:
Name | Type | Description |
---|---|---|
int |
int
|
face id |
direct_face(u, v, return_inds=False)
Pair (u,v) of vertex -> triangle to the left of edge (u,v) if edge (u,v) exists, None otherwise Also returns local indexes of u and v in the triangle (and None if (u,v) does not exists)
Calling this function with edge (v,u) yield the triangle of the other side of the edge
Parameters:
Name | Type | Description | Default |
---|---|---|---|
u |
int
|
first vertex index |
required |
v |
int
|
second vertex index |
required |
return_inds |
bool
|
Whether to return local indices of u and v in the face. Defaults to False. |
False
|
Returns:
Type | Description |
---|---|
Index of a face or None. If return_inds is True, tuple made of index of face and local indices of u and v in face or (None,None,None). |
edge_id(V1, V2)
id of an edge. If self.edges[i]
contains edges (A,B)
, then edge_id(A,B)=edge_id(B,A)=i
If (A,B) is not a valid edge of the mesh, returns None
Parameters:
Name | Type | Description | Default |
---|---|---|---|
V1 |
int
|
first vertex of the edge |
required |
V2 |
int
|
second vertex of the edge |
required |
Returns:
Name | Type | Description |
---|---|---|
int |
int
|
the id of edge (V1,V2), or |
edge_to_vertices(E)
Returns the two vertex indices that are adjacent to edge `E
Parameters:
Name | Type | Description | Default |
---|---|---|---|
E |
int
|
edge index |
required |
Returns:
Name | Type | Description |
---|---|---|
list |
list
|
two vertex indices |
face_id(*args)
The id of a face Args: int*: integers representing indices of vertices of the face (not necessarily in the correct order)
Returns:
Name | Type | Description |
---|---|---|
int |
int
|
A face index or None if the given tuple is invalid |
face_to_corners(F)
list of corners of face F
Parameters:
Name | Type | Description | Default |
---|---|---|---|
F |
int
|
face id |
required |
Returns:
Name | Type | Description |
---|---|---|
list |
list
|
list of corners of face |
face_to_edges(F)
List of edges that bound face F
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
F |
int
|
face id |
required |
Returns:
Name | Type | Description |
---|---|---|
list |
list
|
list of edges |
face_to_faces(F)
List of faces that are adjacent to face `F
Parameters:
Name | Type | Description | Default |
---|---|---|---|
F |
int
|
face id |
required |
Returns:
Name | Type | Description |
---|---|---|
list |
list
|
list of faces |
face_to_first_corner(F)
One corner C
of the face F
(the first in order of appearance in the face_corners
container)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
F |
int
|
face id |
required |
Returns:
Name | Type | Description |
---|---|---|
int |
int
|
corner id |
face_to_vertices(F)
Neighborhood of face F
in terms of vertices.
Note
Equivalent to mesh.faces[F]
Parameters:
Name | Type | Description | Default |
---|---|---|---|
F |
int
|
face id |
required |
Returns:
Name | Type | Description |
---|---|---|
list |
list
|
list of vertices |
in_face_index(F, V)
Index of vertex V in face F. None if V is not in face F
Parameters:
Name | Type | Description | Default |
---|---|---|---|
F |
int
|
face index |
required |
V |
int
|
vertex index |
required |
Returns:
Type | Description |
---|---|
int |
next_corner(C)
Next corner of C
around its associated face
Parameters:
Name | Type | Description | Default |
---|---|---|---|
C |
int
|
corner index |
required |
Returns:
Name | Type | Description |
---|---|---|
int |
int
|
index of the next corner |
opposite_corner(C)
Opposite corner of C
in terms of half edges.
If C.vertex = A
and C.next.vertex = B
, then returns the corner D such that D.vertex = B
and D.vertex.next = A
Parameters:
Name | Type | Description | Default |
---|---|---|---|
C |
int
|
corner index |
required |
Returns:
Name | Type | Description |
---|---|---|
int |
int
|
index of the opposite corner |
opposite_face(u, v, T, return_inds=False)
Given a pair of vertices (u,v) and a face T, returns the face (and local indexes of u and v) on the other side of edge (u,v)
if (u,v) are not two vertices of the face T, returns None
other_edge_end(E, V)
Vertex at the opposite end of edge E
from vertex V
.
Returns None
if V
is not adjacent to edge E
Parameters:
Name | Type | Description | Default |
---|---|---|---|
E |
int
|
edge id |
required |
V |
int
|
vertex id |
required |
Returns:
Name | Type | Description |
---|---|---|
int |
int
|
the vertex |
previous_corner(C)
Previous corner of C
around its associated face
Parameters:
Name | Type | Description | Default |
---|---|---|---|
C |
int
|
corner index |
required |
Returns:
Name | Type | Description |
---|---|---|
int |
int
|
index of the previous corner |
vertex_to_corner_in_face(V, F)
The corner C
corresponding to vertex V
in face F
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
V |
int
|
vertex id |
required |
F |
int
|
face id |
required |
Returns:
Name | Type | Description |
---|---|---|
int |
int
|
corner id, or |
vertex_to_corners(V)
List of face corners that correspond to vertex V
Parameters:
Name | Type | Description | Default |
---|---|---|---|
V |
int
|
vertex id |
required |
Returns:
Name | Type | Description |
---|---|---|
list |
list
|
the list of corners |
vertex_to_edges(V)
Neighborhood of vertex V
in terms of edges.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
V |
int
|
vertex id |
required |
Returns:
Name | Type | Description |
---|---|---|
list |
list
|
list of edges E such that V belongs to E. |
vertex_to_faces(V)
Neighborhood of vertex V
in terms of faces.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
V |
int
|
vertex id |
required |
Returns:
Name | Type | Description |
---|---|---|
list |
list
|
list of faces |
vertex_to_vertices(V)
Neighborhood of vertex V
in terms of vertices.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
V |
int
|
vertex id |
required |
Returns:
Name | Type | Description |
---|---|---|
list |
list
|
list of vertices |